Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
markdown-to-ast
Advanced tools
Parse Markdown to AST with location info.
This library is not parser itself, it dependent on wooorm/remark.
Markdown -> remark -> markdown-to-ast ->
TxtNode
s
The AST consists of TxtNode
s.
A TxtNode
of the AST has following properties:
loc
- Nodes have line and column-based location info.range
- Nodes have an index-based location range (array).raw
- Node have a raw
text.value
- Node have a value
of text.The interface are defined in textlint/txtnode.md
This library is a part of textlint/textlint.
If you need to markdown parser, please use wooorm/remark directly.
Online Parsing Demo provide markdown to AST on-the-fly.
npm install markdown-to-ast
var parse = require("markdown-to-ast").parse;
var markdown = "It's a *text*";
var AST = parse(markdown);
/*
{
"type": "Document",
"children": [
{
"type": "Paragraph",
"children": [
{
"type": "Str",
"value": "It's a ",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
0,
7
],
"raw": "It's a "
},
{
"type": "Emphasis",
"children": [
{
"type": "Str",
"value": "text",
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 12
}
},
"range": [
8,
12
],
"raw": "text"
}
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
7,
13
],
"raw": "*text*"
}
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
0,
13
],
"raw": "It's a *text*"
}
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"range": [
0,
13
],
"raw": "It's a *text*"
}
*/
If you want to know real use-case, please see textlint/textlint.
npm test
See tools/ directory.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
FAQs
Parse Markdown to AST with location info.
We found that markdown-to-ast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.